package com.witsight.hibernate.converter;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

import com.witsight.hibernate.model.City.Gender;

/**   
 * 说明：[]
 * @Title: GenderConverter.java 
 * @Package com.witsight.hibernate.converter 
 * @See: []
 * Copyright: Copyright (c) 2017
 * Company:sany huax witsight team by product
 * @author: fuyp  
 * @date: 2017年9月13日 上午11:19:28 
 * @version: V1.0
 *
 */
@Converter
public class GenderConverter implements AttributeConverter<Gender, Character> {
	 public Character convertToDatabaseColumn( Gender value ) {
	        if ( value == null ) {
	            return null;
	        }

	        return value.getCode();
	    }

	    public Gender convertToEntityAttribute( Character value ) {
	        if ( value == null ) {
	            return null;
	        }

	        return Gender.fromCode( value );
	    }
}
